package my.sample.command;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ExecuteCommand {

	public static void main(String[] args) throws InterruptedException {
		
        String command = "/usr/bin/free -m";

        try {
            Runtime runtime = Runtime.getRuntime();
            Process vty = runtime.exec(command);

            BufferedReader reader=new BufferedReader(new InputStreamReader(vty.getInputStream()));
            String line=reader.readLine();
            while(line!=null)
            {
                System.out.println(line);
                line=reader.readLine();
            }
            
            
          int exitValue = vty.waitFor();
              System.out.println("exit value : " + exitValue);

        } catch (IOException e) {
            e.printStackTrace();
        //} catch (InterruptedException e) {
            //e.printStackTrace();
        }

		
		
	}
}